package com.hfy.pcberpbackend.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 物料实体类
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("materials")
public class Material {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 物料编码
     */
    @NotBlank(message = "物料编码不能为空")
    @Size(min = 2, max = 30, message = "物料编码长度必须在2-30个字符之间")
    @TableField("material_code")
    private String materialCode;
    
    /**
     * 物料名称
     */
    @NotBlank(message = "物料名称不能为空")
    @Size(min = 2, max = 100, message = "物料名称长度必须在2-100个字符之间")
    @TableField("material_name")
    private String materialName;
    
    /**
     * 物料类型
     */
    @TableField("material_type")
    private String materialType;
    
    /**
     * 规格型号
     */
    @TableField("specification")
    private String specification;
    
    /**
     * 单位
     */
    @TableField("unit")
    private String unit;
    
    /**
     * 供应商ID
     */
    @TableField("supplier_id")
    private Long supplierId;
    
    /**
     * 状态
     */
    @NotBlank(message = "状态不能为空")
    @Pattern(regexp = "^(active|inactive)$", message = "状态必须是active或inactive")
    @TableField("status")
    private String status;
    
    /**
     * 逻辑删除
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
    
    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
    
    /**
     * 供应商名称（关联查询字段，不存储在数据库）
     */
    @TableField(exist = false)
    private String supplierName;
} 